/*
 * @Author: zhaopeng
 * @Date:   2016-01-14 16:05:56
 * @Last Modified by:   mikey.zhaopeng
 * @Last Modified time: 2016-07-13 16:53:26
 */

'use strict';
define([
    'select2'
], function(
    imageModel
) {
    function BaseView() {
        var self = this;
        self._ = _;
        self.kit = kit;
        this.baseInit = function() {}

        this.render = function() {}

        this.event = function() {}


        /**
         * 渲染成为html for t
         * @private
         * @method t
         * @param {Object} selector 选择器
         * @param {Object} data
         * @return {Object} description
         */
        this.t = function(selector, data) {
            if (data == undefined || data == null) {
                data = {}
            }
            var tpl = $(selector).text();
            var html = _.template(tpl)({
                d: data
            });
            return html;
        }

        /**
         * 计算出总页数 for culTotalPageNum
         * @private
         * @method culTotalPageNum
         * @param {Object} totalNum 总数
         * @param {Object} pageSize 每页条数
         * @return {Object} description
         */
        this.culTotalPageNum = function(totalNum, pageSize) {
            var totalPageNum = (totalNum * 1 + pageSize * 1 - 1) / (pageSize * 1);
            return Math.floor(totalPageNum);
        }

            /**
             * 生成分页 for generatePager
             * @private
             * @method generatePager
             * @param {Object} pagination
             * @param {Object} pageData
             * @return {Object} description
             */
            /*
        this.generatePager = function(pagination, pageData) {
            var cPage = Number(pageData.cPage || 0), //当前页
                tPage = Number(pageData.tPage || 0), //总页数
                tHtml = '', //临时存储分页HTML片段
                lHtml = ''; //临时存储末尾页码THML片段
            //配置首页
            if (cPage > 1 && tPage > 1) {
                tHtml += '<li cPage="1">' + '<a href="javascript:void(0);">首页</a>' + '</li>' + '<li cPage="' + (cPage - 1) + '">' + '<a href="javascript:void(0);">上一页</a>' + '</li>';
            } else {
                tHtml += '<li class="disabled">' + '<a href="javascript:void(0);">首页</a>' + '</li>' + '<li class="disabled">' + '<a href="javascript:void(0);">上一页</a>' + '</li>';
            }
            var i = 1, //循环开始数
                maxI = tPage; //循环结束数
            //配置first端省略符
            if (cPage > 4) {
                tHtml += '<li cPage="1">' + '<a href="javascript:void(0);">1</a>' + '</li>' + '<li class="disabled">' + '<a href="javascript:void(0);">...</a>' + '</li>';
                i = cPage - 2;
            }
            //配置last端省略符
            if ((tPage - cPage) > 4) {
                maxI = cPage + 2;
                lHtml += '<li class="disabled">' + '<a href="javascript:void(0);">...</a>' + '</li>' + '<li cPage="' + tPage + '">' + '<a href="javascript:void(0);">' + tPage + '</a>' + '</li>';
            }
            // 配置页码
            for (i; i <= maxI; i++) {
                if (i == cPage) {
                    tHtml += '<li class="active">' + '<a href="javascript:void(0);">' + cPage + '</a>' + '</li>';
                    continue;
                }
                tHtml += '<li cPage="' + i + '">' + '<a href="javascript:void(0);">' + i + '</a>' + '</li>';
            }
            tHtml += lHtml;
            //配置下一页与尾页
            if (cPage < tPage) {
                tHtml += '<li cPage="' + (cPage + 1) + '">' + '<a href="javascript:void(0);">下一页</a>' + '</li>' + '<li cPage="' + tPage + '">' + '<a href="javascript:void(0);">尾页</a>' + '</li>';
            } else {
                tHtml += '<li class="disabled">' + '<a href="javascript:void(0);">下一页</a>' + '</li>' + '<li class="disabled">' + '<a href="javascript:void(0);">尾页</a>' + '</li>';
            }
            pagination.html(tHtml);
        }
*/
    };
    return BaseView;
});
